package com.unionwo.service;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.unionwo.dao.ComplainLogDao;
import com.unionwo.dao.RewardDao;
import com.unionwo.json.ComplainRecord;
import com.unionwo.json.RewardResponse;
import com.unionwo.model.ComplainLog;
import com.unionwo.model.Reward;
import com.unionwo.model.UnionResponse;
@Service("checkUpdateService")
/****
 * 
 * @author admin
 *意见反馈
 */
public class RewardService implements UnionService{
	@Autowired
	RewardDao rewardDao;
	@Autowired
	ComplainLogDao complainLogDao;
	
	private Logger log = Logger.getLogger(RewardService.class);
	@Override
	public UnionResponse doRequest(HttpServletRequest request) throws Exception {
		RewardResponse res = new RewardResponse();
		String phone = request.getParameter("n");
		List<Reward> rewardList = null;
		rewardList = rewardDao.selectReward(phone);
		res.setList(rewardList);
		List<ComplainLog> list = complainLogDao.selectUserRecord(phone);
		List<ComplainRecord> crList = new ArrayList<ComplainRecord>();
		ComplainRecord cr = new ComplainRecord();
		for(ComplainLog c : list){
			cr.setP(c.getProvince());
			cr.setC(c.getCity());
			cr.setA(c.getArea());
			cr.setD(c.getAddress());
			cr.setTime(c.getTimes().getTime());
			crList.add(cr);
		}
		res.setCr(crList);
		return res;
	}

}
